/*
 * @Descripttion:
 * @version:
 * @Author: Quan
 * @Date: 2020-01-09 10:29:39
 * @LastEditors  : Quan
 * @LastEditTime : 2020-01-12 17:30:28
 */

import Vue from "vue";
const mixin_list = {
  methods: {
    toPath(path, meta) {
      var data = {};
      if (meta) {
        path = path.slice(1);
        data = {
          name: path,
          params: meta
        };
      } else {
        data = {
          path: path
        };
      }
      this.$router.push(data);
    },
    changeTag(item, list = []) {
      // console.log("====>>>: changeTag -> item, list", item, list)
      if (!item.disabled) {
        list.forEach((item, index) => {
          item.isActive = false;
        });
        item.isActive = true;
        let curPath = this.$router.history.current.fullPath;
        if (item.path && curPath != item.path) {
          this.toPath(item.path);
        }
      }
    },
    changeMenuTag(item, tmpPath = "") {
      let list = Vue.prototype.menu;
      if (!item.disabled) {
  
        list.forEach((item2, index) => {
          item2.isActive = false;
            if(tmpPath!==''){
              if (item2.path == tmpPath) {
                list[index].isActive = true;
              }
            }else{
              if (item2.path == item.path) {
                list[index].isActive = true;
              }
            }
          
        });

        let curPath = this.$router.history.current.fullPath;
        if (item.path && curPath != item.path) {
          this.toPath(item.path);
        }
      }
    }
  }
};

export default mixin_list;
